package com.log.james.mapper;

import com.log.james.entity.WebFlow;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.Date;
import java.util.List;
import java.util.Map;

@Mapper
public interface FlowDao {
    /**
     * 查询特定时间段内的流量值
     * @param st
     * @param et
     * @return
     */
    @Select("SELECT * FROM weblogflow WHERE starttime >= #{st} and endtime <= #{et}")
    List<WebFlow> findFlowByTime(@Param("st") Date st, @Param("et") Date et);

    /**
     * 查询该时间段的流量
     * @param time
     * @return
     */
    @Select("select f.curstream as curStream,f.upstream as maxStream, f.downstream as minStream from weblogflow f where f.endTime = #{time}")
    Map<String,Object> getWebFlow(@Param("time")Date time);
}